# Makefile for sexp-sharp.

MCS = gmcs
MCSFLAGS = -debug -d:DEBUG

SOURCES = SexpSharp/Parser.cs \
	SexpSharp/ParseException.cs \
	SexpSharp/ParseCallback.cs \
	SexpSharp/MultiCallback.cs \
	SexpSharp/Expression.cs \
	SexpSharp/Atom.cs \
	SexpSharp/List.cs \
	SexpSharp/Utils.cs \
	SexpSharp.Serialization/SexpFormatter.cs \
	SexpSharp.Serialization/SexpSerialOptions.cs \
	SexpSharp.Serialization/SexpServices.cs \
	SexpSharp.Remoting/SexpClientFormatterSinkProvider.cs \
	SexpSharp.Remoting/SexpClientFormatterSink.cs \
	SexpSharp.Remoting/SexpServerFormatterSinkProvider.cs \
	SexpSharp.Remoting/SexpServerFormatterSink.cs \
	SexpSharp.Remoting/SexpCall.cs \
	SexpSharp.Remoting/SexpResponse.cs \
	SexpSharp.Remoting/SexpFault.cs \
	SexpSharp.Remoting/SexpMethodResponseMessage.cs \
	SexpSharp.Remoting/SexpMethodCallMessage.cs \
	SexpSharp.Remoting/SexpRemotingOptions.cs \
	SexpSharp.Remoting/RemotableMethod.cs \
	SexpSharp.RPC/IValue.cs \
	SexpSharp.RPC/Values.cs \
	SexpSharp.RPC/BoolValue.cs \
	SexpSharp.RPC/IntegerValue.cs \
	SexpSharp.RPC/RealValue.cs \
	SexpSharp.RPC/StringValue.cs \
	SexpSharp.RPC/DataValue.cs \
	SexpSharp.RPC/DateTimeValue.cs \
	SexpSharp.RPC/ArrayValue.cs \
	SexpSharp.RPC/StructValue.cs \
	SexpSharp.RPC/RPCException.cs \
	SexpSharp.RPC/NullValue.cs \
	SexpSharp.RPC/DictionaryValue.cs \
	SexpSharp.RPC/VectorValue.cs \
	SexpSharp.RPC/MethodCall.cs \
	SexpSharp.RPC/MethodFault.cs \
	SexpSharp.RPC/MethodResponse.cs \
	SexpSharp.RPC/ProxyBase.cs \
	SexpSharp.RPC/Proxies.cs \
	SexpSharp.RPC/ProxyGenException.cs \
	SexpSharp.RPC/SRPCMethodAttribute.cs \
	SexpSharp.RPC/RPCClient.cs

all: SexpSharp.dll

SexpSharp.dll: $(SOURCES)
	$(MCS) $(MCSFLAGS) -keyfile:sexp-sharp.snk -r:System.Runtime.Remoting -target:library -out:$@ $^

check: SexpSharpTest.exe SexpFormatterTest.dll Test3.exe RemotingTest.dll RPCTest.dll
	errors=0
	-mono --debug SexpSharpTest.exe || let 'errors = errors + 1'
	-nunit-console2 SexpFormatterTest.dll || let 'errors = errors + 1'
	-mono --debug Test3.exe || let 'errors = errors + 1'
	-nunit-console2 RemotingTest.dll || let 'errors = errors + 1'
	-nunit-console2 RPCTest.dll || let 'errors = errors + 1'
	@if [ $errors != 0 ]; then false; fi

SexpSharpTest.exe: SexpSharp/Test.cs SexpSharp.dll
	$(MCS) $(MCSFLAGS) -lib:. -target:exe -out:$@ -reference:SexpSharp.dll SexpSharp/Test.cs

SexpFormatterTest.dll: SexpSharp.Serialization.Tests/Test1.cs SexpSharp.Serialization.Tests/Test2.cs SexpSharp.dll TestObjects.dll
	$(MCS) $(MCSFLAGS) -lib:. -target:library -out:$@ -r:nunit.framework.dll -r:SexpSharp.dll -r:TestObjects.dll SexpSharp.Serialization.Tests/Test1.cs SexpSharp.Serialization.Tests/Test2.cs

Test3.exe: SexpSharp.Serialization.Tests/Test3.cs SexpSharp.dll
	$(MCS) $(MCSFLAGS) -lib:. -target:exe -out:$@ -r:SexpSharp.dll SexpSharp.Serialization.Tests/Test3.cs

TestObjects.dll: SexpSharp.Serialization.Tests/Samples.cs
	$(MCS) $(MCSFLAGS) -lib:. -target:library -out:$@ -r:SexpSharp.dll $<

RemotingTest.dll: SexpSharp.Remoting.Tests/Test1.cs SexpSharp.Remoting.Tests/Test2.cs SexpSharp.dll
	$(MCS) $(MCSFLAGS) -lib:. -target:library -out:$@ -r:SexpSharp.dll -r:nunit.framework.dll -r:System.Runtime.Remoting SexpSharp.Remoting.Tests/Test1.cs SexpSharp.Remoting.Tests/Test2.cs

RPCTest.dll: SexpSharp.RPC.Tests/TestProxy.cs SexpSharp.dll
	$(MCS) $(MCSFLAGS) -lib:. -target:library -out:$@ -r:SexpSharp.dll -r:nunit.framework.dll SexpSharp.RPC.Tests/TestProxy.cs 

clean:
	rm -f SexpSharp.dll SexpSharpTest.exe SexpFormatterTest.exe
